import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import *
testcase = "dbshop019-添加属性"
firefox = openBrowser(urlAdmin)
DBshopLoginAdmin(firefox)
DBshopEnterMenu3(firefox,"商品管理","商品属性","属性")

# 1.点击“添加属性”按钮，
firefox.find_element_by_xpath('//a[contains(.,"添加属性")]').click()
# 编写属性分组“好好学习”，属性类型“下拉”，属性名称“天天向上”，排序“255”。
firefox.find_element_by_id("attribute_group_id").click()
firefox.find_element_by_xpath('//option[@value="9"]').click()

firefox.find_element_by_id("attribute_name").send_keys(attributeName)
# 2.点击“保存属性信息”按钮，保存成功。
firefox.find_element_by_xpath('//button[contains(.,"保存属性信息")]').click()
time.sleep(5)

# 断言
try :
    firefox.find_element_by_xpath('//td[contains(.,"%s")]'%(attributeName)).is_displayed()
    writeLog("%s 测试通过"%testcase)
except:
    writeLog("%s 测试失败" % testcase)
    getPhoto(firefox)
# firefox.quit()